package com.tengju.bff.interfaces.shared;

import com.tengju.user.domain.shared.ResultCodeEnum;
import lombok.Getter;

import static com.tengju.user.domain.shared.ResultCodeEnum.SYS_EXCEPTION;

/**
 * 参数异常错误类
 * Created by develop at 2020/9/9.
 */
@Getter
public class SystemException extends RuntimeException {

    private final Integer errorCode;

    private final String errorMessage;


    public SystemException() {
        this.errorCode = SYS_EXCEPTION.getCode();
        this.errorMessage = SYS_EXCEPTION.getMsg();
    }

    public SystemException(String errorMessage) {
        super(errorMessage);
        this.errorCode = SYS_EXCEPTION.getCode();
        this.errorMessage = errorMessage;
    }

    public SystemException(String message, Throwable cause) {
        super(message, cause);
        this.errorCode = SYS_EXCEPTION.getCode();
        this.errorMessage = message;
    }

    public SystemException(ResultCodeEnum resultCode) {
        super(resultCode.getMsg());
        this.errorCode = resultCode.getCode();
        this.errorMessage = resultCode.getMsg();
    }
}
